package cn.xuchunh.exam;

import java.util.Scanner;

/**
 * 输入一组序列表示某股票各时间点的价格，只有一次买入和卖出，求最大的利润
 * Created by XuChunH on 2016/9/17.
 */
public class MaxGain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] params = scanner.nextLine().split(",");
        int[] array = new int[params.length];
        for (int i = 0; i < params.length; i++) {
            array[i] = Integer.valueOf(params[i]);
        }
        int gain = 0;
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = i + 1; j < array.length; j++) {
                int temp = array[j] - array[i];
                if(gain < temp){
                    gain = temp;
                }
            }
        }
        System.out.println(gain);
    }
}
